package top.truehaku.generator.code.application.command;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

public class CodeGroup {

    /**
     * 数据库库名,默认为当前数据库库名(选填)
     */
    @Getter
    private String tableSchema;

    /**
     * 数据库库名(必填)
     */
    @Getter
    private String tableName;

    @Getter
    private List<TargetCode> codes;

    @Getter
    private Class<?> baseEntity;

    private CodeGroup(String tableSchema, String tableName){
        this.tableSchema = tableSchema;
        this.tableName = tableName;
        this.codes = new ArrayList<>();
    }

    public static CodeGroup init(String tableSchema, String tableName){
        return new CodeGroup(tableSchema,tableName);
    }

    public static CodeGroup init(String tableName){
        return new CodeGroup(null,tableName);
    }

    public CodeGroup setBaseEntity(Class<?> baseEntity){
        this.baseEntity = baseEntity;
        return this;
    }

    public void addCode(TargetCode code){
        this.codes.add(code);
    }

}
